package com.hualan.controller;

import com.hualan.domain.User;
import com.hualan.service.impl.UserService;
import com.hualan.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userbfb")
public class UserControllerbfb {
    @Autowired
    private UserService userService;

    @GetMapping("/getAllAdUser")
    public R getAllAdUser(){
        return R.success(userService.findAllAdUser());
    }

    //登陆业务 //vue
    @GetMapping("/login")
    public R userLogin(String username, String password){
        int num = userService.findAdUserByUsername(username,password);
        if (num == 0){
            return R.success(num);
        }else if (num == 11){
            return R.success(num);
        }else if (num == 21){
            return R.success(num);
        }else {
            return R.success(num);
        }
    }

    @GetMapping("/getAllNUser")
    public R getAllNUser(){
        return R.success(userService.findAllNUser());
    }

    @GetMapping("/getAllNormalConsultantUser")
    public R getAllNormalConsultantUser(){
        return R.success(userService.findAllNormalConsultantUser());
    }

    @GetMapping("/getLikeNormalConsultantUser")
    public R getLikeNormalConsultantUser(String message){
        return R.success(userService.findLikeNormalConsultantUser(message));
    }

    @PostMapping("/insertNormalConsultantUser")
    public R insertNormalConsultantUser(User user){
        return R.success(userService.insertUserNormalConsultant(user));
    }

    @PostMapping("/updateNormalConsultantUser")
    public R updateNormalConsultantUser(User user){
        return R.success(userService.updateUserNormalConsultant(user));
    }

    @DeleteMapping("/deleteNormalConsultantUser")
    public R deleteNormalConsultantUser(Long id){
        return R.success(userService.deleteUserNormalConsultant(id));
    }

}
